package com.yinhe.music.yhmusic.login.password;

import com.yinhe.music.yhmusic.base.BasePresenter;
import com.yinhe.music.yhmusic.base.IBaseModel;
import com.yinhe.music.yhmusic.network.response.ResponseTransformer;

public class PassWordPresenter extends BasePresenter<IBaseModel, PasswordContract.IPassWordView> implements PasswordContract.IPassWordPresenter {
    @Override
    public void setPassWord(String type, String phone, String validCode, String password) {
        if (getView() == null) {
            return;
        }

        getView().showLoading();

        addSubscription(mModel.setPassword(type, phone, validCode, password)
                .compose(ResponseTransformer.handleResult())
                .compose(schedulerProvider.applySchedulers())
                .subscribe(loginInfo -> {
                    getView().hideLoading();
                    getView().setPassWordUI(loginInfo);
                }, throwable -> {
                    getView().hideLoading();
                    getView().showMessage(throwable);
                }));
    }
}
